<?php

namespace Modules\Admin\Http\Controllers\Subscribe;

use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Modules\Common\General\Security\Api\Gateway;
use Modules\Common\Models\AdminLog;
use Modules\Common\Models\SubscriptionTypes;
use Modules\Common\Util\Api;
use Modules\Common\Util\Database;


class Create
{

    /**
     *
     * @Route(path=/api/admin/subscribe  method=post)
     */
    public function index()
    {
        $adminUserIdDefault = auth('api')->user()->id;
        $eidDefault = auth('api')->user()->eid; 
        $sidDefault = auth('api')->user()->sid; 
        
        $subscriptionTypes = new SubscriptionTypes();
        $subscriptionTypes->name = request('name');
        $subscriptionTypes->duration = request('duration');
        $subscriptionTypes->price = request('price');
        $subscriptionTypes->underlined_price = request('underlined_price');
        $subscriptionTypes->description = request('description');
        $subscriptionTypes->is_permanent = request('is_permanent');
        $subscriptionTypes->status = request('status');
        $subscriptionTypes->admin_user_id = $adminUserIdDefault;
        $subscriptionTypes->eid = $eidDefault;
        $subscriptionTypes->sid = $sidDefault;
        $subscriptionTypes->created_at = date('Y-m-d H:i:s');
        $subscriptionTypes->save();
        
        return Api::success();
    }
}